package hu;

import java.util.*;

public class dna_list {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int n = sc.nextInt();
        int b = 0, e = 0;
        int nums = 0;
        for (int i = 0; i < str.length() - n + 1; i++) {
            int m = 0;
            int j = i;
            for (; j < i + n; j++) {
                if(str.charAt(j) == 'C' || str.charAt(j) == 'G')
                    m++;
            }
            if(m > nums){
                nums = m;
                b = i;
                e = j;
            }
        }
        System.out.println(str.substring(b, e));
    }
}
